var BaseTutorRegStep3 = app.controller('BaseTutorRegStep3', function($http, $scope, $rootScope, $location,$cordovaDevice,$cordovaChat,$cordovaDatePicker,BaseTutorRegStep3Data) {
	try{
		$rootScope.showf=false;

		//获取用户信息
		$scope.user={};
		$scope.hopedate='';
		$scope.datestr='';
		var url=SITE_URL+"index.php?app=baseloginapp&callback=JSON_CALLBACK&act=userinfo";
		$http.jsonp(url).success(function(data) {
			$scope.user=data.retval;
			if($rootScope.btrs1_tel!=undefined&&$rootScope.btrs1_tel!=""&&$rootScope.btrs1_tel!=null){
				$scope.user.tutor.tel=$rootScope.btrs1_tel;
			}
		});
		//修改手机号页面
		$scope.go_tel=function(){
			if($scope.user.tutor.tel!=undefined&&$scope.user.tutor.tel!=null){
				$rootScope.btrs1_tel=$scope.user.tutor.tel;
			}
			$rootScope.go('tutortel');
		}
		
		if($scope.hopedate==null||$scope.hopedate==''){
			datetim=new Date();
			var m=datetim.getFullYear()+"/"+(datetim.getMonth()+1)+"/"+datetim.getDate()+" "+datetim.getHours()+":"+datetim.getMinutes()+":00";
			$scope.datestr=(datetim.getMonth()+1)+"月"+datetim.getDate()+"日"+" "+datetim.getHours()+":"+datetim.getMinutes();
			if(datetim.getMinutes()<10){
				m=datetim.getFullYear()+"/"+(datetim.getMonth()+1)+"/"+datetim.getDate()+" "+datetim.getHours()+":0"+datetim.getMinutes();
				$scope.datestr=(datetim.getMonth()+1)+"月"+datetim.getDate()+"日"+" "+datetim.getHours()+":0"+datetim.getMinutes();
			}
			$scope.hopedate=m;
		}
		
		//选择日期
		$scope.setdate = function(){
			if($scope.hopedate==''){
				datetim=new Date();
				timedate=new Date(datetim.getFullYear()+"/"+(datetim.getMonth()+1)+"/"+datetim.getDate()+" "+datetim.getHours()+":"+datetim.getMinutes());
			}else{
				timedate=new Date($scope.hopedate);
			}
			var options = {
					date: timedate,
					mode: 'datetime', // or 'time'
					doneButtonLabel: '确定',
					doneButtonColor: '#000000',
					cancelButtonLabel: '取消',
					cancelButtonColor: '#000000'
			};
			$cordovaDatePicker.show(options).then(function(date){
				var year=date.getFullYear();
				var month=date.getMonth()+1;
				var day=date.getDate();
				var hour=date.getHours();
				var minute=date.getMinutes();
				if(month<10){
					month="0"+month;
				}
				if(day<10){
					day="0"+day;
				}
				if(hour<10){
					hour="0"+hour;
				}
				if(minute<10){
					minute="0"+minute;
				}
				$scope.hopedate=date.getFullYear()+"/"+month+"/"+day+" "+hour+":"+minute+":00";
				$scope.datestr=month+"月"+day+"日"+" "+hour+":"+minute;
			});
		};
		
		$scope.busy=false;
		
		//提交操作
		$scope.submit=function(){
			if($scope.busy){
				return false;
			}
			
			$rootScope.btrs1_tel="";
			var tel=$scope.user.tutor.tel;
			var hopedate='';
			if(tel==""||tel==undefined||tel==null){
				showtoast("请填写手机号");
				return false;
			}
			//if(hopedate==""||hopedate==undefined||hopedate==null){
				//showtoast("请填写希望对答时间");
				//return false;
			//}
			$scope.busy=true;
			var url=SITE_URL+"index.php?app=baseloginapp&callback=JSON_CALLBACK&act=confirmtutor&tel="+tel+"&date="+$scope.hopedate;
			$http.jsonp(url).success(function(data) {
				showtoast(data.msg);
				$rootScope.go('ucenter');
				$scope.busy=false;
			}).error(function() {
				$scope.busy=false;
			});
		}
	}
	catch (e) {
		showcatch(e);
	}
});
BaseTutorRegStep3.BaseTutorRegStep3Data=function($q, $http,$stateParams,$rootScope){
	try {
		var data = [];
		var def = $q.defer();
		if(window.localStorage.u==undefined||window.localStorage.u==null||window.localStorage.u==""){			
			$rootScope.go("loginmain");
		}else{
			def.resolve(data);
		}
		
		return def.promise;
	} catch (e) {
		showcatch(e);
	}
}